"""
monteCarlo算法求pi
"""
from random import random

num = 1000000
inner_point = 0
for i in range(num):
    x = random()
    y = random()
    if x ** 2 + y ** 2 <= 1:
        inner_point += 1
pi = (inner_point / num) * 4
print(pi)
